Format inline CASE <expression> WHEN correctly#86
Merged
shssoichiro merged 3 commits intoshssoichiro:masterfrom Aug 15, 2025
Merged
Format inline CASE <expression> WHEN correctly#86shssoichiro merged 3 commits intoshssoichiro:masterfrom
shssoichiro merged 3 commits intoshssoichiro:masterfrom
Conversation
shssoichiro
reviewed
Aug 15, 2025
| toolchain: nightly | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - uses: actions/checkout@v5 |
Owner
There was a problem hiding this comment.
I guess I should get dependabot set up on this repo
Contributor
Author
There was a problem hiding this comment.
Yes, it would be good.
There was a problem hiding this comment.
Pull Request Overview
This PR fixes the formatting of inline CASE expressions to ensure proper whitespace handling. The primary change ensures that inline CASE statements have a space added before them when inside an inline block.
- Updates four instances in the tokenizer to use
next_back()instead oflast()for better performance - Adds whitespace handling for inline CASE expressions in the formatter
- Includes a test case to verify the fix for CASE expressions in ORDER BY clauses
- Updates GitHub Actions workflow dependencies
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/tokenizer.rs | Replaces split(' ').last() with split(' ').next_back() for performance optimization |
| src/formatter.rs | Adds space before inline CASE expressions to fix formatting |
| src/lib.rs | Adds test case for CASE WHEN expressions inside ORDER BY clauses |
| .github/workflows/sqlformat.yml | Updates GitHub Actions to use newer versions of checkout, cache, and toolchain actions |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CASEENDand(and)have different requirements regarding the whitespace